HAL GENERIC migration: List of applicable concepts

This section provides information about the HAL GENERIC applicable architecture concepts.

Concepts for GENERIC

Concept

Description

Separation of initialization and configuration functions

Split initialization into separate initialization and configuration functions (example for the VREFBUF driver):

  • No dedicated initialization function and no handle are required.

  • Configuration: use HAL_VREFBUF_SetConfig() to set the voltage scaling and VREFBUF functional mode using the hal_vrefbuf_config_t structure.

Remove MspInit and MspDeInit callbacks

HAL_MspInit() and HAL_MspDeInit are no longer available and have been replaced by a user sequence .

Unitary configuration APIs

Introduce new unitary configuration APIs such as HAL_VREFBUF_SetVoltageScale() and HAL_VREFBUF_GetVoltageScale()

HAL implementation with LL inline functions

HAL GENERIC APIs now rely on LL APIs rather than performing direct register access.

Define statements and enumerations redirected to LL equivalents

HAL GENERIC define statements and enumerations are based on LL define statements.

Removal of hardware-related macros in HAL2

All hardware macros have been removed from the HAL GENERIC driver, and equivalent services are ensured through the LL APIs.

Revised and optimized HAL API status returns

Update SYSCFG/SBS, DGBMCU and VREFBUF functions to return:

  • HAL_INVALID_PARAM: in case of a NULL p_config structure pointer.

  • HAL_ERROR: in case of an error.

  • HAL_BUSY: in case of an ongoing process.

  • HAL_OK: in case of a successfully completed operation.

Replaced TypeDef suffix with _t in type names

All TypeDef parts of the HAL GENERIC driver have been removed and replaced by _t.

Replaced multi-line macros with inline functions

For the HAL GENERIC driver, large macros have been replaced by inline functions to maintain code consistency, improve readability, and benefit from compiler optimization. Inline functions also offer better support for debugging and strict type management, reducing the risk of errors.

Assertion implementation and usage in HAL1

The parameters and state are checked using ASSERT_DBG_STATE and ASSERT_DBG_PARAM macro.

Cleanup the HAL configuration file

HAL_Module_ENABLED has been renamed to USE_HAL_MODULE.

Cleanup stm32tnxx_hal.c/h and move HAL module includes to stm32_hal.h

Refactor stm32tnxx_hal.c/h by moving module include directives to stm32_hal.h and separating the SYSCFG, VREFBUF, and DBGMCU APIs into dedicated modules.

Replace Finite Parameter Defines (Including PPP Instances) with Enum Types at HAL Levels.

Finite parameters (for DBGMCU, SYSCFG/SBS, and VREFBUF drivers) have been converted into enumerated types (enums) at HAL level. This improves code readability, maintainability, and type safety.

Add HAL_PPP Prefix to All HAL Peripheral APIs (Defines, Macros, Types, and Functions).

All HAL DBGMCU ,SYSCFG/SBS and VREFBUF functions start with HAL_.